package com.tcl.api.response;

import com.fasterxml.jackson.annotation.JsonInclude;
import com.tcl.api.code.ErrorEnum;

import java.io.Serializable;

/**
 * @Author liuf
 * @Date 2021/1/6 20:07
 * @Description
 */
public class ResultMsg<T> implements Serializable {
    private static final long serialVersionUID = 1L;
    private int code;
    private String message;
    private T data;

    public ResultMsg() {
        this.setErrorEnum(ErrorEnum.SUCCESS);
    }

    public ResultMsg(ErrorEnum errorEnum) {
        this.code = errorEnum.getCode();
        this.message = errorEnum.getMessage();
    }

    public ResultMsg(ErrorEnum errorEnum, T data) {
        this.code = errorEnum.getCode();
        this.message = errorEnum.getMessage();
        this.data = data;
    }

    public void setErrorEnum(ErrorEnum errorEnum) {
        this.code = errorEnum.getCode();
        this.message = errorEnum.getMessage();
    }

    public int getCode() {
        return this.code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return this.message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public T getData() {
        return this.data;
    }

    public void setData(T data) {
        this.data = data;
    }

    @Override
    public String toString() {
        return "ResultMsg{code=" + this.code + ", message='" + this.message + '\'' + ", data=" + this.data + '}';
    }
}

